<?php
namespace app\common\controller;
use app\common\controller\All;
use think\Db;
class Home extends All{
	//栏目页变量定义
	public function Lable_List($param,$array_list){
		$array_list['list_page'] = !empty($param['page']) ? $param['page'] : 1;
		//$array_list['thisurl'] = str_replace('zanpianpage',$param['page'],zanpian_list_url($this->request->module().'/'.$this->request->controller().'/'.$this->request->action(),array('id'=>$array_list['list_id'],'dir'=>$array_list['list_dir'],'p'=>$param['page'])));	
		if (empty($array_list['list_skin'])) {
			$array_list['list_skin'] = $array_list['name'].'_list';
		}
		if (empty($array_list['list_skin_type'])) {	
			$array_list['list_skin_type'] = $array_list['name'].'_type';
		}
		return $array_list;
	}
	//生成播放列表字符串
	public function playlist_json($vod_info_array,$vod_url_array, $json = false){
		if(empty($vod_url_array)){return false;}
		//json数组创建
		$key = 0;
		$config_player = F('_data/player');
		$authcode = new \com\AuthCode();
		//print_r($vod_url_array) ;
		foreach($vod_url_array as $val){
			$array_urls[$key]['servername'] = "";
			$array_urls[$key]['playname'] = $val['player_name'];
			$array_urls[$key]['playtitle'] = $val['player_title'];
			foreach($val['son'] as $keysub=>$valsub){
				$video = array($valsub["playname"], $valsub["playpath"], $valsub["playurl"]);
				if($config_player[$val["player_name"]]['play_key']){
					$video[1] = base64_encode($authcode->authcode(trim($video[1]),"ENCODE",$config_player[$val["player_name"]]['play_key'],$config_player[$val["player_name"]]['play_keytime']));
				}
				$array_urls[$key]["playurls"][$keysub] = $video;
			}
			$key++;
		}
		return $json ? array('Vod'=>$vod_info_array,'Data'=>$array_urls) : json_encode(array('Vod'=>$vod_info_array,'Data'=>$array_urls));
	}
	//标签变量定义
	public function Lable_Tag($param,$array_list){
		$array_list['list_page'] = !empty($param['page']) ? $param['page'] : 1;
		//$array_list['thisurl'] = str_replace('zanpianpage',$param['page'],zanpian_list_url($this->request->module().'/'.$this->request->controller().'/'.$this->request->action(),array('id'=>$array_list['id'],'dir'=>$array_list['name'],'tag'=>urlencode($param['tag']),'p'=>$param['page'])));	
		$array_list['list_skin'] = $array_list['name'].'_tag_list';
		return $array_list;
    }	
	
	public function Lable_Vod($array){
		$array['vod_readurl'] = zanpian_data_url('home/vod/read',array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>getlistname($array['vod_cid'],'list_dir'),'jumpurl'=>$array['vod_jumpurl']));
		$array['vod_playurl'] = zanpian_play_url(array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>$array_list[0]['list_dir'],'sid'=>0,'pid'=>1));
		$array['vod_picurl'] = zanpian_img_url($array['vod_pic']);
		$array['vod_bigpicurl'] = zanpian_img_url($array['vod_bigpic']);
		$array['vod_picurl_small'] = zanpian_img_smallurl($array['vod_pic']);
		$array['vod_hits'] = gethits(1,'news_hits',$array);
		$array['vod_hits_insert'] = gethits(1,'insert',$array);
		$array['vod_hits_month'] = gethits(1,'vod_hits_month',$array);
		$array['vod_hits_week'] = gethits(1,'vod_hits_week',$array);
		$array['vod_hits_day'] = gethits(1,'vod_hits_day',$array);
		$array['vod_content']  = $array['vod_content'];
		return $array;
	}
	
	/*****************影视内容,播放页公用变量定义******************************
	* @$array/具体的内容信息
	* @$array_play 为解析播放页
	* @返回赋值后的arrays 多维数组*/
	public function Lable_Vod_Read($array,$array_play=false){
		$array = $this->Lable_Vod($array);
		$array_list = list_search(F('_data/list'),'list_id='.$array['vod_cid']);	
		//$array['thisurl'] = $array['vod_readurl'];
		$lastplayurl = play_url_end($array['vod_url'],$array['vod_play']);
        $array['vod_lastname'] = $lastplayurl[2];
		$array['vod_lasturl'] = zanpian_play_url(array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>$array_list[0]['list_dir'],'sid'=>$lastplayurl[0],'pid'=>$lastplayurl[1]));
		if($array['vod_skin']){
			$array['vod_skin_detail'] = trim($array['vod_skin']);
			if(config('player_http')==1 || $array['vod_copyright']==2){
			$array['vod_skin_play'] = trim($array['vod_skin']).'_play_blank';
			}else{
			$array['vod_skin_play'] = trim($array['vod_skin']).'_play';	
			}
		}else{
			$array['vod_skin_detail'] = !empty($array_list[0]['list_skin_detail']) ? $array_list[0]['list_skin_detail'] : 'vod_detail';
			if(config('player_http')==1 || $array['vod_copyright']==2){
			$array['vod_skin_play'] = !empty($array_list[0]['list_skin_play']) ? $array_list[0]['list_skin_play'].'_blank' : 'vod_play_blank';
			}else{
			$array['vod_skin_play'] = !empty($array_list[0]['list_skin_play']) ? $array_list[0]['list_skin_play'] : 'vod_play';	
			}
		}
        //播放列表解析
		$playlist = playlist_all($array,$array_list[0]['list_dir']);
		//按顺序排列
		if($playlist[0] && $array['vod_copyright']!=1){
		if(empty($array['vod_playoid'])){
		ksort($playlist[0]);
		}
		$array['vod_playlist']=$playlist[0];
		$array['vod_countplay']=count($playlist[0]);
		}
		if($playlist[1] && $array['vod_copyright']!=1){
		$array['vod_downlist']=$playlist[1];	
		}
		$array['vod_diantai'] = implode(',',model('Vodtv')->tv_data($array['vod_id'],1));	
		$arrays['show'] = $array_list[0];
		//剧情解析
		if($array['story_id'] && $array['story_status']==1){		
		$array['story_readurl']= zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir')));
		}else{
		unset($array['story_id']);	
		}
		if($array['actor_id'] && $array['actor_status']==1){
		$array['actor_readurl']= zanpian_data_url('home/actor/read',array('id'=>$array['actor_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['actor_cid'],'dir'=>getlistname($array['actor_cid'],'list_dir')));	   
		}else{
		unset($array['actor_id']);	
		}
		unset($array['vod_url']);
		$arrays['read'] = $array;
		return $arrays;
	}	
	/*****************影视播放页变量定义 适用于动态与合集为一个播放页******************************<br />
	* @$array 内容页解析好后的内容页变量 arrays['read']
	* @$array_play 为播放页URL参数 array('id'=>558,'sid'=>1,'pid'=>1)
	* @返回$array 内容页重新组装的数组*/
	public function Lable_Vod_Play($array,$array_list,$array_play){
		$player = F('_data/player');
		$player_here = explode('$$$',$array['vod_play']);
		 foreach ($player_here  as $key=>$value){
          //过滤不存在以及禁用的播放器	
          if(empty($player[$value]) || $player[$value]['play_display']==0 || $value=="down"){
          unset($player_here[$key]);
          }	 
		}
		$player_here=array_values($player_here);
		$array['vod_hits_month'] = gethits(1,'vod_hits_month',$array,config('url_html_play'));
		$array['vod_hits_week'] = gethits(1,'vod_hits_week',$array,config('url_html_play'));
		$array['vod_hits_day'] = gethits(1,'vod_hits_day',$array,config('url_html_play'));
		//$array['thisurl'] = zanpian_play_url(array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>$array_list['list_dir'],'sid'=>$array_play['sid'],'pid'=>$array_play['pid']));
		$play=$array['vod_playlist'][$player[$player_here[$array_play['sid']]]['play_oid'].'-'.$array_play['sid']];
		// 播放器相关默认配置
		$array['vod_sid']=$array_play['sid'];
		$array['vod_pid']=$array_play['pid'];
		$array['vod_jiname']=$play['son'][$array_play['pid']-1]['playname'];
		$array['play_name'] = $play['player_name'];
		$array['play_title'] = $play['player_title'];
		$array['play_sid'] = $array_play['sid'];
		$array['play_pid'] = $array_play['pid'];
		$array['play_oid'] = $player[$play['player_name']]['play_oid'];
		$array['play_width'] = config('player_width');
		$array['play_height'] = config('player_height');
		$array['play_adurl'] = config('player_playad');
		$array['play_second'] = intval(config('player_second'));
		$array['play_apiurl'] = trim(config('player_api'));
		$array['play_count'] = $play['player_count'];
		$array['play_key'] = $play['son'][$array_play['pid']-1]['playkey'];
		$array['play_jiname']=$play['son'][$array_play['pid']-1]['playname'];
		$array['play_pic']= $play['son'][$array_play['pid']-1]['playpic'];
		$array['play_fen']= $play['son'][$array_play['pid']-1]['playfen'];
		$array['play_miao']= $play['son'][$array_play['pid']-1]['playmiao'];
		$array['play_source']= $play['son'][$array_play['pid']-1]['playsource'];
		$array['play_path']= $play['son'][$array_play['pid']-1]['playpath'];
		if($array_play['pid']-1 >0){
		$array['play_prevpath']= $play['son'][$array_play['pid']-1]['playpath'];
		$array['play_prevurl']=zanpian_play_url(array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>$array_list['list_dir'],'sid'=>$array_play['sid'],'pid'=>$array_play['pid']-1));
		}
		$array['play_nextpath']= $play['son'][$array_play['pid']]['playpath'];
		$array['play_lastpath']= $play['son'][$array['play_count']-1]['playpath'];
		$array['play_lasturl']=zanpian_play_url(array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>$array_list['list_dir'],'sid'=>$array_play['sid'],'pid'=>$play['player_count']));
		$array['play_nexturl']=zanpian_play_url(array('id'=>$array['vod_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['vod_cid'],'dir'=>$array_list['list_dir'],'sid'=>$array_play['sid'],'pid'=>$array_play['pid']+1));
		$array['play_urllist'] = $play['son'];
		
		//付费点播处理
		$array['play_vipplay'] = 0;
		$array['play_pay'] = 0;
		$array['play_trysee'] = 0;
		
		if($array_list['list_vipplay']){
			$array['play_vipplay'] = intval($array_list['list_vipplay']);
		}
		if($array_list['list_pay']){
			$array['play_pay'] = intval($array_list['list_pay']);
		}
		if($array_list['list_trysee']){
			$array['play_trysee'] = intval($array_list['list_trysee']);
		}
		if($array['vod_vipplay']){
			$array['play_vipplay'] = intval($array['vod_vipplay']);
		}
		if($array['vod_pay']){
			$array['play_pay'] = intval($array['vod_pay']);
		}
		if($array['vod_trysee']){
			$array['play_trysee'] = intval($array['vod_trysee']);
		}
		// 解析服务器变量处理
		if($play['player_apiurl']){
			$array['play_apiurl'] = str_replace('{playname}',$array['play_name'], $play['player_apiurl']);
		}elseif($array['play_apiurl']){
			$array['play_apiurl'] = str_replace('{playname}',$array['play_name'], $array['play_apiurl']);
		}
		//播放器调用
		if($array['play_vipplay'] || $array['play_pay']){//付费与注册用户点播
			$array['vod_player'] = '<div id="zanpiancms-player-vip"><div class="zanpiancms-player-box">影片需验证观看权限，请稍等。</div><iframe class="zanpiancms-player-iframe" src="'.zp_url('home/vod/vip',array('type'=>'play','id'=>$array['vod_id'],'sid'=>$array['play_sid'],'pid'=>$array['play_pid'])).'" width="100%" height="100%" frameborder="0"></iframe></div>';
		}else{
			if($play['player_copyright'] > 0 ){
			$array['player_copyright']=intval($play['player_copyright']);	
		    }	
			$array['vod_player'] = zanpiancms_player($array);
		}		
		return $array;
	}	
	public function Lable_Vod_Play_Vip($array,$array_list,$array_play){
		$player = F('_data/player');
		$player_here = explode('$$$',$array['vod_play']);
		foreach ($player_here  as $key=>$value){
          //过滤不存在以及禁用的播放器	
          if(empty($player[$value]) || $player[$value]['play_display']==0 || $value=="down"){
          unset($player_here[$key]);
          }	 
		}
		$player_here=array_values($player_here);
		$play=$array['vod_playlist'][$player[$player_here[$array_play['sid']]]['play_oid'].'-'.$array_play['sid']];
		$vip['play_id'] = $array['vod_id'];
		$vip['play_sid'] = $array_play['sid'];
		$vip['play_pid'] = $array_play['pid'];
		$vip['play_name'] = $play['player_name'];
		$vip['play_title'] = $play['player_title'];		
		$vip['play_width'] = config('player_width');
		$vip['play_height'] = config('player_height');
		$vip['play_apiurl'] = trim(config('player_api'));
        $vip['play_key'] = $play['son'][$array_play['pid']-1]['playkey'];
		$vip['play_jiname']=$play['son'][$array_play['pid']-1]['playname'];
		$vip['play_pic']= $play['son'][$array_play['pid']-1]['playpic'];
		$vip['play_fen']= $play['son'][$array_play['pid']-1]['playfen'];
		$vip['play_miao']= $play['son'][$array_play['pid']-1]['playmiao'];
		$vip['play_source']= $play['son'][$array_play['pid']-1]['playsource'];
		$vip['play_path']= $play['son'][$array_play['pid']-1]['playpath'];
		$vip['play_nextpath']= $play['son'][$array_play['pid']]['playpath'];
		$vip['play_lastpath']= $play['son'][$play['player_count']-1]['playpath'];
		$vip['play_status'] = 200;
		//缓冲广告与版权跳转
		$vip['play_adurl'] = 0;
		$vip['play_second'] = 0;
        $vip['play_copyright']=0;		
		//付费点播处理
		$vip['play_vipplay'] = 0;
		$vip['play_pay'] = 0;
		$vip['play_trysee'] = 0;
		if($array_list['list_vipplay']){
			$vip['play_vipplay'] = intval($array_list['list_vipplay']);
		}
		if($array_list['list_pay']){
			$vip['play_pay'] = intval($array_list['list_pay']);
		}
		if($array_list['list_trysee']){
			$vip['play_trysee'] = intval($array_list['list_trysee']);
		}
		if($array['vod_vipplay']){
			$vip['play_vipplay'] = intval($array['vod_vipplay']);
		}
		if($array['vod_pay']){
			$vip['play_pay'] = intval($array['vod_pay']);
		}
		if($array['vod_trysee']){
			$vip['play_trysee'] = intval($array['vod_trysee']);
		}
		// 解析服务器变量处理
		if($play['player_apiurl']){
			$vip['play_apiurl'] = str_replace('{playname}',$array['play_name'], $play['player_apiurl']);
		}elseif($array['play_apiurl']){
			$vip['play_apiurl'] = str_replace('{playname}',$array['play_name'], $array['play_apiurl']);
		}
		$vip['vod_player'] = zanpiancms_player($vip);
		return $vip;	
		
	}
	public function Lable_Story_Read($array){
		$array['story_hits'] = gethits(4,'story_hits',$array);
		$array['story_hits_insert'] = gethits(4,'insert',$array);
		$array['story_hits_month'] = gethits(4,'story_hits_month',$array);
		$array['story_hits_week'] = gethits(4,'story_hits_week',$array);
		$array['story_hits_day'] = gethits(4,'story_hits_day',$array);
		$array_list = list_search(F('_data/list'),'list_id='.$array['story_cid']);
		$vod_list = list_search(F('_data/list'),'list_id='.$array['vod_cid']);	
		if($array['story_skin']){
			$array['story_skin'] = trim($array['vod_skin']);
		}else{
			$array['story_skin'] = !empty($array_list[0]['list_skin_detail']) ? $array_list[0]['list_skin_detail'] : 'story_detail';
		}
		if($array['vod_id']){
		$array = $this->Lable_Vod($array);
		}else{
		unset($array['vod_id']);		
		}
		$array['story_list']=$this->Lable_Story_Read_List($array);
		if($array['actor_id'] && $array['actor_status']==1){
		$array['actor_readurl']= zanpian_data_url('home/actor/read',array('id'=>$array['actor_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['actor_cid'],'dir'=>getlistname($array['actor_cid'],'list_dir')));	
		}else{
		unset($array['actor_id']);		
		}
		unset($array['story_content']);
		$arrays['show'] = $array_list[0];
		$arrays['read']=$array;
		return $arrays;
		
	}
    //剧情内容
	public function Lable_Story_Read_List($array){
			if(!empty($array['story_content'])){//如果存在剧情
			$array['story_content']=$array['story_content'];
			$listarray=explode('||',$array['story_content']); //将每一集分组
			foreach($listarray as $key=>$jiinfo){
				$k=$key+1;
				$jiinfoarray=explode('@@',$jiinfo);
				$arrays['story_list'][$key+1]['story_name']=$jiinfoarray[0];
				$arrays['story_list'][$key+1]['story_title']=$jiinfoarray[1];
				$arrays['story_list'][$key+1]['story_info']=$jiinfoarray[2];
				$arrays['story_list'][$key+1]['story_page']=$k;
                if($k==1){
				$arrays['story_list'][$k]['story_url']=zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir')));
				if($array['vod_storypage'] !=1){
				$arrays['story_list'][$k]['story_nexturl']=str_replace('zanpianpage',$k+1,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'),'p'=>$k+1)));
				}
				}elseif($k==$array['story_page']){
				$arrays['story_list'][$k]['story_prevurl']=str_replace('zanpianpage',$k-1,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'),'p'=>$k-1)));	
				$arrays['story_list'][$k]['story_url']=str_replace('zanpianpage',$k,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'),'p'=>$k)));
					}
				else{
					$arrays['story_list'][$k]['story_url']=str_replace('zanpianpage',$k,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'),'p'=>$k)));
					if($k==2){
					$arrays['story_list'][$k]['story_prevurl']=str_replace('zanpianpage',$k-1,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'))));
					}
					else{
					$arrays['story_list'][$k]['story_prevurl']=str_replace('zanpianpage',$k-1,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'),'p'=>$k-1)));	
					}
					$arrays['story_list'][$k]['story_nexturl']=str_replace('zanpianpage',$k+1,zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir'),'p'=>$k+1)));
					
				}
			}
			return $arrays['story_list'];	
		}
	else{
		return false;
		}
	}
	public function Lable_Actor_Read($array){
		$array['actor_hits'] = gethits(6,'actor_hits',$array);
		$array['actor_hits_insert'] = gethits(6,'insert',$array);
		$array['actor_hits_month'] = gethits(6,'actor_hits_month',$array);
		$array['actor_hits_week'] = gethits(6,'actor_hits_week',$array);
		$array['actor_hits_day'] = gethits(6,'actor_hits_day',$array);		
		$array['actor_readurl']= zanpian_data_url('home/actor/read',array('id'=>$array['actor_id'],'pinyin'=>$array['homevod']['vod_letters'],'cid'=>$array['actor_cid'],'dir'=>getlistname($array['actor_cid'],'list_dir')));
		//$array['thisurl']= zanpian_data_url('home/actor/read',array('id'=>$array['actor_id'],'pinyin'=>$array['homevod']['vod_letters'],'cid'=>$array['actor_cid'],'dir'=>getlistname($array['actor_cid'],'list_dir')));	
		$array_list = list_search(F('_data/list'),'list_id='.$array['actor_cid']);
		$vod_list = list_search(F('_data/list'),'list_id='.$array['homevod']['vod_cid']);	
		if($array['actor_skin']){
			$array['actor_skin'] = trim($array['actor_skin']);
		}else{
			$array['actor_skin'] = !empty($array_list[0]['list_skin_detail']) ? $array_list[0]['list_skin_detail'] : 'actor_detail';
		}		
		if($array['homevod']){
		$arrays['vod'] = $this->Lable_Vod($array['homevod']);
		}
		$array_list = list_search(F('_data/list'),'list_id='.$array['actor_cid']);
		$vod_list = list_search(F('_data/list'),'list_id='.$array['homevod']['vod_cid']);
		if($array['homestory']){
		$array['story_id']=$array['homestory']['story_id'];
		$array['story_cid']=$array['homestory']['story_cid'];
		$array['story_readurl']= zanpian_data_url('home/story/read',array('id'=>$array['homestory']['story_id'],'pinyin'=>$array['homevod']['vod_letters'],'cid'=>$array['homestory']['story_cid'],'dir'=>getlistname($array['homestory']['story_cid'],'list_dir')));	
		}
		if($array['homerole']){
		$arrays['role']=$this->Lable_Actor_Role($array);
		$array['actor_count']=count($array['homerole']);
		   if($array['actor_count']%4 !=0){
			   $array['actor_num']=(4-($array['actor_count']%4));
		   }else{
			   $array['actor_num']=0;
		   }
		}
		unset($array['homevod'],$array['homestory'],$array['homerole']);
		$arrays['show'] = $array_list[0];
		$arrays['actor']=$array;
		return $arrays;
		
		
	}	
	//演员表角色列表
	public function Lable_Actor_Role($array){
		if(!empty($array['homerole'])){ 
		foreach ($array['homerole'] as $key =>$value){
			$array_actor['role_list'][$value['role_id']]=$value;
			$array_actor['role_list'][$value['role_id']]['role_content']=$value['role_content'];
			$array_actor['role_list'][$value['role_id']]['role_picurl']=zanpian_img_url($value['role_pic']);
			$array_actor['role_list'][$value['role_id']]['role_readurl']=zanpian_data_url('home/role/read',array('id'=>$value['role_id'],'pinyin'=>$array['homevod']['vod_letters'],'cid'=>$value['role_cid'],'dir'=>getlistname($value['role_cid'],'list_dir')));
			if($value['star_id']){
			$array_actor['role_list'][$value['role_id']]['star_picurl']=zanpian_img_url($value['star_pic']);
			$array_actor['role_list'][$value['role_id']]['star_readurl']=zanpian_data_url('home/star/read',array('id'=>$value['star_id'],'pinyin'=>$value['star_letters'],'cid'=>$value['star_cid'],'dir'=>getlistname($value['star_cid'],'list_dir')));
			}else{
			$array_actor['role_list'][$value['role_id']]['star_picurl']=zanpian_img_url(false);	
			$array_actor['role_list'][$value['role_id']]['star_readurl']=zanpian_url('home/search/index',array('wd'=>urlencode(trim($value['role_star']))),true,false);	
			}
		}
	    return $array_actor;
		}
		else{
		return false;
		}
	}	
 public function Lable_Role_Read($array){
		$array['role_picurl'] = zanpian_img_url($array['role_pic']);
		$array['role_picurl_small'] = zanpian_img_smallurl($array['role_pic']);
		$array['role_content']  = $array['role_content'];
		$array['role_hits'] = gethits(5,'role_hits',$array);
	    $array['role_hits_insert'] = gethits(5,'insert',$array);
		$array['role_hits_month'] = gethits(5,'role_hits_month',$array);
		$array['role_hits_week'] = gethits(5,'role_hits_week',$array);
		$array['role_hits_day'] = gethits(5,'role_hits_day',$array);		
		$array['role_readurl']= zanpian_data_url('home/role/read',array('id'=>$array['role_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['role_cid'],'dir'=>getlistname($array['role_cid'],'list_dir')));
		//$array['thisurl']= zanpian_data_url('home/role/read',array('id'=>$array['role_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['role_cid'],'dir'=>getlistname($array['role_cid'],'list_dir')));
		$array_list = list_search(F('_data/list'),'list_id='.$array['role_cid']);
		if($array['role_skin']){
			$array['role_skin'] = trim($array['role_skin']);
		}else{
			$array['role_skin'] = !empty($array_list[0]['list_skin_detail']) ? $array_list[0]['list_skin_detail'] : 'role_detail';
		}		
		if($array['vod_id']){
		 $array = $this->Lable_Vod($array);
		}
		if($array['story_id'] && $array['story_status']==1){
		$array['story_id']=$array['story_id'];
		$array['story_readurl']= zanpian_data_url('home/story/read',array('id'=>$array['story_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['story_cid'],'dir'=>getlistname($array['story_cid'],'list_dir')));	
		}else{
		unset($array['story_id']);	
		}
		if($array['star_id'] && $array['star_status']==1){
		$array['star_readurl'] = zanpian_data_url('home/star/read',array('id'=>$array['star_id'],'pinyin'=>$array['star_letters'],'cid'=>$array['star_cid'],'dir'=>getlistname($array['star_cid'],'list_dir')));
		$array['star_picurl'] = zanpian_img_url($array['star_pic']);
		$array['star_picurl_small'] = zanpian_img_smallurl($array['star_pic']);
		}else{
		unset($array['star_id']);	
		$array['star_readurl'] = zanpian_url('home/search/index',array('wd'=>urlencode(trim($array['role_star']))));	
		$array['star_picurl'] = zanpian_img_url(false);
		$array['star_picurl_small'] = zanpian_img_url(false);		
		}
		if($array['actor_id'] && $array['actor_status']==1){
		 	$array['actor_readurl']=zanpian_data_url('home/actor/read',array('id'=>$array['actor_id'],'pinyin'=>$array['vod_letters'],'cid'=>$array['actor_cid'],'dir'=>getlistname($array['actor_cid'],'list_dir')));
		}else{
		  unset($array['actor_id']);	
		}		
		$arrays['show'] = $array_list[0];
        $arrays['read']=$array;
	   return $arrays;
	
}
	//资讯内容页变量定义
	public function Lable_News_Read($array,$params){
        $array_list = list_search(F('_data/list'),'list_id='.$array['news_cid']);
		$array['news_readurl'] = str_replace('zanpianpage',$params['page'],zanpian_data_url('home/news/read',array('id'=>$array['news_id'],'cid'=>$array['news_cid'],'dir'=>$array_list[0]['list_dir'],'p'=>$params['page'],'jumpurl'=>$array['news_jumpurl'])));
		//$array['thisurl'] = $array['news_readurl'];
		$array['news_picurl'] = zanpian_img_url($array['news_pic']);
		$array['news_picurl_small'] = zanpian_img_url($array['news_pic']);
		$array['news_hits'] = gethits($array_list[0]['list_sid'],'news_hits',$array);
		$array['news_hits_insert'] = gethits($array_list[0]['list_sid'],'insert',$array);
		$array['news_hits_month'] = gethits($array_list[0]['list_sid'],'news_hits_month',$array);
		$array['news_hits_week'] = gethits($array_list[0]['list_sid'],'news_hits_week',$array);
		$array['news_hits_day'] = gethits($array_list[0]['list_sid'],'news_hits_day',$array);
		$array['news_contents']  = $array['news_content'];
		$array['news_images_array']  = zanpian_img_url_array($array['news_content']);
		$array['news_images_count'] = count($array['news_images_array']);
		$array_content = preg_split("/#zanpianpage#/", $array['news_contents']);
		$slideimg = config('news_images');
		//内容页面是否有分页标签
		if(count($array_content)>1){	
		    $array['news_page_count'] = count($array_content);
			foreach($array_content as $key=>$value){
			 $key=$key+1;	
			 $array['news_pages'][$key]['news_content'] = zanpian_news_img_array($value);
		     $array['news_pages'][$key]['news_pagelist']=getnewspage('home/news/read',array('id'=>$array['news_id'],'cid'=>$array['news_cid'],'dir'=>$array_list[0]['list_dir'],'p'=>"zanpianpage",'jumpurl'=>$array['news_jumpurl']),$key,$array['news_page_count'],3);//数字分页	
			 $array['news_pages'][$key]['news_page']=$key;
			}
			unset($array['news_images_array']);
			unset($array['news_content']);  
		}
		//内容模式为图片分页
		if($array['news_mid']==2 && $array['news_images_count']>1){
		    $array['news_page_count']= $array['news_images_count'];
		    if($array['news_page_count']>1){	
			 //$array['images_slide'][$key]['news_pagelist']=getnewspage('home/news/read',array('id'=>$array['news_id'],'cid'=>$array['news_cid'],'dir'=>$array_list[0]['list_dir'],'p'=>"zanpianpage",'jumpurl'=>$array['news_jumpurl']),$key,$array['news_page_count'],config('home_pagenum'),$jumpurl);//数字分页
			  foreach($array['news_images_array'] as $key=>$value){
			  $key=$key+1;	  
			  if($key==1){	
			  $array['images_slide'][$key]['news_content']  = zanpian_news_images_array($array['news_content']);
			  }			  
		      $array['images_slide'][$key]['news_images_content']=$value;
			  $array['images_slide'][$key]['news_pageprevurl']  = getpageprev('home/news/read',array('id'=>$array['news_id'],'cid'=>$array['news_cid'],'dir'=>$array_list[0]['list_dir'],'p'=>"zanpianpage",'jumpurl'=>$array['news_jumpurl']),$key,$array['news_page_count'],3);
			  $array['images_slide'][$key]['news_pagenexturl']  = getpagenext('home/news/read',array('id'=>$array['news_id'],'cid'=>$array['news_cid'],'dir'=>$array_list[0]['list_dir'],'p'=>"zanpianpage",'jumpurl'=>$array['news_jumpurl']),$key,$array['news_page_count'],3);
		      $array['images_slide'][$key]['news_pagelist']=getnewspage('home/news/read',array('id'=>$array['news_id'],'cid'=>$array['news_cid'],'dir'=>$array_list[0]['list_dir'],'p'=>"zanpianpage",'jumpurl'=>$array['news_jumpurl']),$key,$array['news_page_count'],3);//数字分页
			  $array['images_slide'][$key]['news_page']=$key;
			  } 		  
		   }
		 unset($array['news_content']);     
		 unset($array['news_images_array']);   
		}
		//内容模式为图片幻灯
		elseif($array['news_mid']==1){
			  $array['news_images_slide']  = zanpian_img_url_array($array['news_content']);	
		      $array['news_page_count']=count($array['news_images_slide']);
			  if($array['news_page_count']>=$slideimg){
			  $array['news_content']  = zanpian_news_images_array($array['news_content']);
			  }else{
			  $array['news_content']  = zanpian_news_img_array($array['news_content']);	  
			  unset($array['news_images_slide']);  
			  }
		}else{
			  $array['news_content']  = zanpian_news_img_array($array['news_content']);	
		}
		unset($array['news_contents']);
		if($array['news_skin']){
			$array['news_skin_detail'] = trim($array['news_skin']);
		}else{
			$array['news_skin_detail'] = !empty($array_list[0]['list_skin_detail']) ? $array_list[0]['list_skin_detail'] : 'news_detail';
		}
		//新闻关联明星视频
		if($array['newsrel']){
			foreach($array['newsrel'] as $key=>$val){
		    $relation[$val['newsrel_sid']][$key]=$val['newsrel_did'];	
			if(!empty($val['newsrel_did'])){			
			   $relationarray[$key]=$val['newsrel_did'];
			}
			   if(empty($val['newsrel_did'])){
		       $relationnamearray[$key]=$val['newsrel_name'];	
			 }
		    }
		    if($relation[1]){
			$array['news_vodid']=implode(',',$relation[1]);
			}
			if($relation[3]){
			$array['news_starid']=implode(',',$relation[3]);
			}
			$relationid=!empty($relationarray) ? implode(',',$relationarray) : '';
			$relationname=!empty($relationnamearray) ? implode(',',$relationnamearray) : '';
			$newsidarray=model('newsrel')->get_newsid($relationid,$relationname);
			$array['news_newsid']=!empty($newsidarray) ? implode(',',$newsidarray) : '';
			unset($array['newsrel']);  	
			} 
		//获取上一篇下一篇
		$nextnews=detail_array($array_list[0]['name'],'next',$array['news_id'],$array['news_cid'],'news_id,news_name,news_cid,news_pic,news_addtime,news_remark,news_jumpurl');
		$prevnews=detail_array($array_list[0]['name'],'prev',$array['news_id'],$array['news_cid'],'news_id,news_name,news_cid,news_pic,news_addtime,news_remark,news_jumpurl');
		if($nextnews){
			$array['news_next']=$nextnews;
			$array['news_next']['news_picurl']=zanpian_img_url($nextnews['news_pic']);
			$array['news_next']['news_readurl']=zanpian_data_url('home/news/read',array('id'=>$nextnews['news_id'],'cid'=>$nextnews['news_cid'],'dir'=>getlistname($nextnews['news_cid'],'list_url'),'jumpurl'=>$nextnews['news_jumpurl']));
		}
		if($prevnews){
			$array['news_prev']=$prevnews;
			$array['news_prev']['news_picurl']=zanpian_img_url($prevnews['news_pic']);
			$array['news_prev']['news_readurl']=zanpian_data_url('home/news/read',array('id'=>$prevnews['news_id'],'cid'=>$prevnews['news_cid'],'dir'=>getlistname($prevnews['news_cid'],'list_url'),'jumpurl'=>$prevnews['news_jumpurl']));
		}
        if(!empty($array['news_playname']) && !empty($array['news_playurl'])){
		$player = F('_data/player');
        $news_player=$player[$array['news_playname']];
        // 解析服务器变量处理
		if($news_player['player_apiurl']){
			$array['play_apiurl'] = str_replace('{playname}',$array['news_playname'], $news_player['player_apiurl']);
		}elseif(trim(config('player_api'))){
			$array['play_apiurl'] = str_replace('{playname}',$array['news_playname'], trim(config('player_api')));
		}
		if(config('player_cloud')){
			$array['news_player'] = '<script src="'.config('player_cloud').'?url='.base64_encode($array['news_playurl']).'&name='.$array['news_playname'].'&co=&api='.base64_encode($array['play_apiurl']).'&time='.config('player_second').'&ad='.base64_encode(config('player_playad')).'"></script>'."\n";
		}else{
			$data = array();
			$data['url'] = $array['news_playurl'];
			$data['copyright'] = "";
			$data['name'] = empty($array['news_playname']) ? "copyright" : $array['news_playname'];
			$data['apiurl'] = $array['play_apiurl'];
			$data['width'] = config('player_width');
			$data['height'] =  config('player_height');
			$data['adtime'] = config('player_second');
			$data['adurl'] =  config('player_playad');
			$array['news_player'] = '<script>var zanpiancms_player = '.json_encode($data).';</script><script src="'.config('site_path').PUBLIC_PATH.'player/'.$data['name'].'.js"></script>';
			unset($data);				
		}			
		}			
		$arrays['show'] = $array_list[0];
		$arrays['read'] = $array;	
		//print_r($arrays); 
		return $arrays;
	}
	//专题内容页变量定义
	public function Lable_Special_Read($array){
		$array_list = list_search(F('_data/list'),'list_id='.$array['special_cid']);
		$array['special_readurl'] = zanpian_data_url('home/special/read',array('id'=>$array['special_id'],'pinyin'=>$array['special_letters'],'cid'=>$array['special_cid'],'dir'=>getlistname($array['special_cid'],'list_dir')));
		//$array['thisurl'] = zanpian_data_url('home/special/read',array('id'=>$array['special_id'],'pinyin'=>$array['special_letters'],'cid'=>$array['special_cid'],'dir'=>getlistname($array['special_cid'],'list_dir')));
		$array['special_logo'] = zanpian_img_url($array['special_logo']);
		$array['special_banner'] = zanpian_img_url($array['special_banner']);
		$array['special_hits'] = gethits($array_list[0]['list_sid'],'special_hits',$array);
		$array['special_hits_insert'] = gethits($array_list[0]['list_sid'],'insert',$array);
		$array['special_hits_month'] = gethits($array_list[0]['list_sid'],'special_hits_month',$array);
		$array['special_hits_week'] = gethits($array_list[0]['list_sid'],'special_hits_week',$array);
		$array['special_hits_day'] = gethits($array_list[0]['list_sid'],'special_hits_day',$array);
		$array['special_content']  = $array['special_content'];
		if($array['special_skin']){
			$array['special_skin'] = trim($array['special_skin']);
		}else{
			$array['special_skin'] = !empty($array_list[0]['list_skin_detail']) ? $array_list[0]['list_skin_detail'] : 'special_detail';
		}	
		//收录影视
		$where['topic_tid'] = $array['special_id'];
		$where['topic_sid'] = 1;
		$list_vod = Db::name('topic')->alias('t')->join('vod v','v.vod_id = t.topic_did','LEFT')->where($where)->order('topic_oid desc,topic_did desc')->select();
		foreach($list_vod as $key=>$val){
		$list_vod[$key]['list_id'] = $list_vod[$key]['vod_cid'];
		$list_vod[$key]['list_name'] = getlistname($list_vod[$key]['vod_cid'],'list_name');
		$list_vod[$key]['list_url'] = getlistname($list_vod[$key]['vod_cid'],'list_url');
		$list_vod[$key]['vod_readurl'] = zanpian_data_url('home/vod/read',array('id'=>$list_vod[$key]['vod_id'],'pinyin'=>$list_vod[$key]['vod_letters'],'cid'=>$list_vod[$key]['vod_cid'],'dir'=>getlistname($list_vod[$key]['vod_cid'],'list_dir'),'jumpurl'=>$list_vod[$key]['vod_jumpurl']));
		$list_vod[$key]['vod_playurl'] = zanpian_play_url(array('id'=>$list_vod[$key]['vod_id'],'pinyin'=>$list_vod[$key]['vod_letters'],'cid'=>$list_vod[$key]['vod_cid'],'dir'=>getlistname($list_vod[$key]['vod_cid'],'list_dir'),'sid'=>0,'pid'=>1));
		$list_vod[$key]['vod_picurl'] = zanpian_img_url($list_vod[$key]['vod_pic']);
		$list_vod[$key]['vod_bigpicurl'] = zanpian_img_url($list_vod[$key]['vod_bigpic']);
		$list_vod[$key]['vod_picurl_small'] = zanpian_img_smallurl($list_vod[$key]['vod_pic']);
		unset($list_vod[$key]['vod_url']);
		}
		//收录资讯
		unset($where);
		$where['topic_sid'] = 2;
		$where['topic_tid'] = $array['special_id'];
		$list_news = Db::name('topic')->alias('t')->join('news n','n.news_id = t.topic_did','LEFT')->where($where)->order('topic_oid desc,topic_did desc')->select();
		foreach($list_news as $key=>$val){
		$list_news[$key]['list_id'] = $val['news_cid'];
		$list_news[$key]['list_name'] = getlistname($val['news_cid'],'list_name');
		$list_news[$key]['list_url'] = getlistname($val['news_cid'],'list_url');
		$list_news[$key]['news_readurl'] = zanpian_data_url('home/news/read',array('id'=>$val['news_id'],'cid'=>$val['news_cid'],'dir'=>getlistname($val['news_cid'],'list_dir'),'jumpurl'=>$val['news_jumpurl']));
		$list_news[$key]['news_picurl'] = zanpian_img_url($val['news_pic']);
		$list_news[$key]['news_picurl_small'] = zanpian_img_smallurl($val['news_pic']);	
		unset($list_news[$key]['news_content']);
		}
		//收录明星
		unset($where);
		$where['topic_sid'] = 3;
		$where['topic_tid'] = $array['special_id'];
		$list_star = Db::name('topic')->alias('t')->join('star s','s.star_id = t.topic_did','LEFT')->where($where)->order('topic_oid desc,topic_did desc')->select();
		foreach($list_star as $key=>$val){
		$list_star[$key]['list_id'] = $val['star_cid'];
		$list_star[$key]['list_name'] = getlistname($val['star_cid'],'list_name');
		$list_star[$key]['list_url'] = getlistname($val['star_cid'],'list_url');
		$list_star[$key]['star_readurl'] = zanpian_data_url('home/star/read',array('id'=>$val['star_id'],'pinyin'=>$val['star_letters'],'cid'=>$val['star_cid'],'dir'=>getlistname($val['star_cid'],'list_dir'),'jumpurl'=>$val['star_jumpurl']));
		$list_star[$key]['star_picurl'] = zanpian_img_url($val['star_pic']);
		$list_star[$key]['star_bigpicurl'] = zanpian_img_url($val['star_bigpic']);
		$list_star[$key]['star_picurl_small'] = zanpian_img_smallurl($val['star_pic']);
		unset($list_star[$key]['star_info']);
		}	
		$arrays['read'] = $array;
		$arrays['show'] = $array_list[0];
		$arrays['list_vod'] = $list_vod;
		$arrays['list_news'] = $list_news;
		$arrays['list_star'] = $list_star;
		return $arrays;
	}			
	//搜索页变量定义
	public function Lable_Search($param){
		if($param['sid']){
		$mode= list_search(F('_data/modellist'),'id='.$param['sid']);
		$array_search = array();
		$array_search['search_modesid'] = $mode[0]['id'];
		$array_search['search_modename'] = $mode[0]['name'];
		$array_search['search_modetitle'] = $mode[0]['title'];
		}
		$array_search['search_actor'] = $param['actor'];
		$array_search['search_director'] = $param['director'];			
		$array_search['search_area'] = $param['area'];
		$array_search['search_langaue'] = $param['langaue'];
		$array_search['search_year'] = $param['year'];
		$array_search['search_wd'] = $param['wd'];
		$array_search['search_name'] = $param['name'];
		$array_search['search_title'] = $param['title'];
		$array_search['search_page'] = !empty($param['page']) ? $param['page'] : 1;
		$array_search['search_letter'] = $param['letter'];
		$array_search['search_order'] = $param['order'];
		$array_search['search_skin'] = !empty($param['sid']) ? 'search_'.$mode[0]['name'] : "search";
		//$array_search['thisurl'] = str_replace('zanpianpage',$param['page'],zanpian_url($this->request->module().'/'.$this->request->controller().'/'.$this->request->action(),array('sid'=>$param['sid'],'actor'=>urlencode($param['actor']),'director'=>urlencode($param['director']),'area'=>urlencode($param['area']),'langaue'=>urlencode($param['langaue']),'year'=>urlencode($param['year']),'name'=>urlencode($param['name']),'title'=>urlencode($param['title']),'wd'=>urlencode($param['wd']),'p'=>$param['page']),true,false));
		return $array_search;
    }
	
	public function Lable_Tv_Read($array){
        $Url['p'] = input('p/d','');		
		$array_list = list_search(F('_data/list'),'list_id='.$array['tv_cid']);
		$array['tv_picurl'] = zanpian_img_url($array['tv_pic'],$array['tv_content']);
		$array['tv_picurl_small'] = zanpian_img_smallurl($array['tv_pic'],$array['tv_content']);
		$array['tv_hits'] = gethits($array_list[0]['list_sid'],'tv_hits',$array);
		$array['tv_hits_insert'] = gethits($array_list[0]['list_sid'],'insert',$array);
		$array['tv_hits_month'] = gethits($array_list[0]['list_sid'],'tv_hits_month',$array);
		$array['tv_hits_week'] = gethits($array_list[0]['list_sid'],'tv_hits_week',$array);
		$array['tv_hits_day'] = gethits($array_list[0]['list_sid'],'tv_hits_day',$array);
		$array['tv_content']  = $array['tv_content'];
		if($array['tv_skin']){
			$array['tv_skin_detail'] = ''.trim($array['tv_skin']);
		}else{
			$array['tv_skin_detail'] = !empty($array_list['list_skin_detail']) ? ''.$array_list['list_skin_detail'] : 'tv_detail';
		}
		//周期列表解析
        $week=str_replace('0','7',date("w"));
		$date=date("Y年m月d日");
		$time=strtotime(date("H:i"));
		$array['tv_wid']=!empty($Url['p']) ? $Url['p'] : $week;
	    if(time() - $array['tv_lasttime'] > 3600*$array['tv_uptime'] && !empty($array['tv_apiid']) && !empty($array['tv_apitype'])){
			$urlarray=config('http_api');
		    $rand = array_rand($urlarray,1);
		    $apiurl="http://".$urlarray[$rand]."/zanpiancms/zanpianjiemu.php?id=".$array['tv_apiid']."&type=".$array['tv_apitype'];
		    $datas = zanpian_get_url($apiurl,15);
			$data=json_decode($datas,true);
			if(!empty($data) && count($data)==7){
			$rs = model("Tv");
			$save['tv_lasttime'] = time();
			$save['tv_data'] = $datas;
			$rs->where('tv_id',$array['tv_id'])->update($save);
		    }
		 else{ 
		 $data=json_decode($array['tv_data'],true);
		 }
			}
		else{
        $data=json_decode($array['tv_data'],true);
		}
		foreach($data as $key=>$value){
			$array_week['week'][]=str_replace(array('星期一','星期二','星期三','星期四','星期五','星期六','星期日'),array('1','2','3','4','5','6','7'),$value['week']);
			$array['tv_week_list'][$key]['wid']=str_replace(array('星期一','星期二','星期三','星期四','星期五','星期六','星期日'),array('1','2','3','4','5','6','7'),$value['week']);
			$array['tv_week_list'][$key]['week']=$value['week'];
			$array['tv_week_list'][$key]['date']=$value['date'];
			if($date==$value['date']){
			$array['tv_week_list'][$key]['day']=1;
			}
			$array['tv_week_list'][$key]['url']=str_replace('zanpianpage',$array['tv_week_list'][$key]['wid'],zanpian_url('home/tv/read',array('id'=>$array['tv_id'],'pinyin'=>$array['tv_letters'],'cid'=>$array['tv_cid'],'dir'=>getlistname($array['tv_cid'],'list_dir'),'p'=>$array['tv_week_list'][$key]['wid'])));
			if($array['tv_wid'] != $week && $array['tv_wid'] == $array['tv_week_list'][$key]['wid']){
			    $array['tv_week_list'][$key]['cut']=1;	
			     }
			elseif($date==$array['tv_week_list'][$key]['date'] && $array['tv_wid'] == $week){
				$array['tv_week_list'][$key]['cut']=1;																														            }
 
			}
			$week = $array_week['week'];
			foreach($data as $key=>$value){
				$array['tv_datalist'][$week[$key]]['wid']=str_replace(array('星期一','星期二','星期三','星期四','星期五','星期六','星期日'),array('1','2','3','4','5','6','7'),$value['week']);
				
				$array['tv_datalist'][$week[$key]]['week']=$value['week'];
				$array['tv_datalist'][$week[$key]]['date']=$value['date'];
				$array['tv_datalist'][$week[$key]]['url']=str_replace('zanpianpage',$array['tv_week_list'][$key]['wid'],zanpian_url('home/tv/read',array('id'=>$array['tv_id'],'pinyin'=>$array['tv_letters'],'cid'=>$array['tv_cid'],'dir'=>getlistname($array['tv_cid'],'list_dir'),'p'=>$array['tv_week_list'][$key]['wid'])));
				if($array['tv_wid'] != $week && $array['tv_wid'] == $array['tv_datalist'][$week[$key]]['wid']){
			    $array['tv_datalist'][$week[$key]]['cut']=1;	
			     }
			    elseif($date==$value['date'] && $array['tv_wid'] == $week){
				$array['tv_datalist'][$week[$key]]['cut']=1;																														                }
				$datas=explode(chr(13),trim($value['data']));
				$len = count($datas);
				$lastVal = end($datas);
				foreach($datas as $k=>$val){
				$datalist=explode('$',$val);
				$ndatalist=explode('$',$datas[$k+1]);
				if($date==$value['date'] && $time >= strtotime($datalist[0]) && $time < strtotime($ndatalist[0]) || $date==$value['date'] && $time >= strtotime($datalist[0]) && $k == $len-1){
				$array['tv_datalist'][$week[$key]]['data'][$k]['live']=1;
				}
				$array['tv_datalist'][$week[$key]]['data'][$k]['time']=$datalist[0];
				$array['tv_datalist'][$week[$key]]['data'][$k]['name']=str_replace('#','',$datalist[1]);
				$datalistkey[$k]=explode('#',$datalist[1]);
			    if(count($datalistkey[$k])>1){
				$array['tv_datalist'][$week[$key]]['data'][$k]['keywords']=$datalistkey[$k][1];	
				}else{
				$array['tv_datalist'][$week[$key]]['data'][$k]['keywords']=preg_replace(array("/.*?:/","/(\(.*?)\)/","/.*?：/","/（(.*?)）/","/\d*/"),"",$datalist[1]);
					}		
			}
		}
		$array['tv_datalistall']=$array['tv_datalist'];
		$array['tv_datalist']=$array['tv_datalist'][$array['tv_wid']];
		$array['tv_title']=$array['tv_datalist']['week'];
		$array['tv_date']=$array['tv_datalist']['date'];
		//$array['tv_url']=$array['tv_datalist']['url'];
		$array['tv_url']=zanpian_data_url('home/tv/read',array('id'=>$array['tv_id'],'pinyin'=>$array['tv_letters'],'cid'=>$array['tv_cid'],'dir'=>getlistname($array['tv_cid'],'list_dir')));
		//$array['thisurl']=$array['tv_url'];
	    $arrays['show'] = $array_list[0];
		unset($array['tv_data']);
        $arrays['read'] = $array;
		return $arrays;
	}
	//首页标签定义
	public function Lable_Index(){
		$array = array();
		$array['title'] = config('site_name');
		$array['model'] = 'index';
		return $array;
	}
	//明星内容页变量定义
	public function Lable_Star_Read($array){
		$array_list = list_search(F('_data/list'),'list_id='.$array['star_cid']);	
		$array['star_readurl'] = zanpian_data_url('home/star/read',array('id'=>$array['star_id'],'pinyin'=>$array['star_letters'],'cid'=>$array['star_cid'],'dir'=>getlistname($array['star_cid'],'list_dir'),'jumpurl'=>$array['star_jumpurl']));
		//$array['thisurl'] = zanpian_data_url('home/star/read',array('id'=>$array['star_id'],'pinyin'=>$array['star_letters'],'cid'=>$array['star_cid'],'dir'=>getlistname($array['star_cid'],'list_dir'),'jumpurl'=>$array['star_jumpurl']));
		$array['star_picurl'] = zanpian_img_url($array['star_pic']);
		if(!empty($array['star_bigpic'])){
		$array['star_bigpicurl'] = zanpian_img_url($array['star_bigpic']);
		}
		$array['star_hits_insert'] = gethits($array_list[0]['list_sid'],'insert',$array);
		$array['star_hits_month'] = gethits($array_list[0]['list_sid'],'star_hits_month',$array);
		$array['star_hits_week'] = gethits($array_list[0]['list_sid'],'star_hits_week',$array);
		$array['star_hits_day'] = gethits($array_list[0]['list_sid'],'star_hits_day',$array);
		$array['star_content']  = $array['star_content'];
		if($array['star_skin']){
			$array['star_skin_detail'] = ''.trim($array['star_skin']);
		}else{
			$array['star_skin_detail'] = !empty($array_list['list_skin_detail']) ? ''.$array_list['list_skin_detail'] : 'star_detail';
		}
		if(!empty($array['star_guanxi'])){
		$guanxiarray=explode(',',$array['star_guanxi']);
		if(!empty($array['star_guanxi'])){
		   foreach($guanxiarray  as $key=>$val){
		    $gx=explode('@@',$val);	
			$guanxi[$key]['title']=	$gx[0];
		    $guanxi[$key]['name']=	$gx[1];
		    $guan[$gx[1]]=$gx[0];
			$xi[$key]=$gx[1];
		    }
		}
		foreach($guanxi as $key=>$val){
		   $stararray=get_star_find($val['name'],'star_name');
		   if(!empty($stararray)){
		    $guan_xi[$key]=$stararray;
		    $guan_xi[$key]['star_gx']=$val['title'];
		    $guan_xi[$key]['star_readurl']=zanpian_data_url('home/star/read',array('id'=>$stararray['star_id'],'pinyin'=>$stararray['star_letters'],'cid'=>$stararray['star_cid'],'dir'=>getlistname($stararray['star_cid'],'list_dir'),'jumpurl'=>$stararray['star_jumpurl']));
		    $guan_xi[$key]['star_picurl'] = zanpian_img_url($stararray['star_pic']);
		    $guan_xi[$key]['star_bigpicurl'] = zanpian_img_url($stararray['star_bigpic']);
		    $guan_xi[$key]['star_picurl_small'] = zanpian_img_smallurl($stararray['star_pic']);
		    $guan_xi[$key]['star_content'] = $stararray['star_content'];
		    unset($guan_xi[$key]['star_info']);
		  }else{
		    unset($guanxi[$key]);	
			}
		}
		$array['star_guanxi']=$guan_xi;
		$array['star_guan']=$guan;
		$array['star_xi']=implode(',',$xi);
		}
        if(!empty($array['star_info'])){		 
		foreach(explode('||',$array['star_info']) as $k=>$val){
				$info=explode('@@',$val);
			    $array['star_data'][$k]['title']=$info[0];
				$array['star_data'][$k]['info']=$info[1];
			}				 
        }
		unset($array['star_info']);	
		$arrays['read'] = $array;	
		$arrays['show'] = $array_list[0];
		return $arrays;
	}
	//明星作品变量定义
	public function Lable_work_Read($array,$array_play = false){
		$array['sid'] = "star";
		$array['title'] = $array['star_name'].'-'.C('site_name');
		$array['star_readurl'] = ff_star_url('read',$array['star_id'],$array['star_pyname'],$page);
		//$array['thisurl'] = ff_star_url('read',$array['star_id'],$array['star_pyname'],$page);
		$array['star_pic'] = ff_img_url($array['star_pic']);
        $array['star_skin']='pp_starwork';
		$arrays['work'] = $array;		
		return $arrays;
	}
    /**
	 * 检测验证码
	 * @param  integer $id 验证码ID
	 * @return boolean     检测结果
	 */
	protected function checkVerify($code, $id = 1) {
		if ($code) {
			$verify = new \org\Verify();
			$result = $verify->check($code, $id);
			if (!$result) {
				return $this->error("验证码错误！");
			}
		} else {
			return $this->error("验证码为空！");
		}
	}
	protected function checkcode($code, $id = 1) {
		if ($code) {
			$verify = new \org\Verify(array('reset' =>false));
			$result = $verify->check($code, $id);
			if (!$result) {
				return "验证码错误";
			}else{
			    return true;
			}
		} else {
			return "验证码为空";
		}
	}		
}
?>